<template>
  <div>
    <data-view
        :columns="columns"
        :data="data"
        :pagination="pagination"
        :missing-value-fill="'-'">
    </data-view>
  </div>
</template>

<script>
import moment from 'moment'
import {createClassroomBuildings, listClassroomBuildings} from "@/api/classroomBuilding";
import DataView from "../../components/DataView";

export default {
  name: "ClassroomBuilding",
  components: { DataView },
  data() {
    return {
      columns: [
        // {
        //   label: "教学楼ID",
        //   prop: "id",
        //   width: "80",
        //   align: "center"
        // },
        {
          label: "教学楼名称",
          prop: "classroomBuildingName",
          align: "center",
        },
        {
          label: "教学楼地点",
          prop: "classroomBuildingPlace",
          align: "center",
        },
        {
          label: "教室位置",
          prop: "classroomPlace",
          align: "center",
        },
        {
          label: "楼层",
          prop: "floor",
          align: "center",
        },
      ],
      data: [],
      pagination: {
        page: 0,
        pageSize: 5,
        total: 10
      },
      multipleSelection: [],
      tableHeight: window.innerHeight - 170,
    }
  },
  created: function () {
    this.fetchData()
  },
  methods: {
    // 刷新数据
    fetchData() {
      listClassroomBuildings(1, this.pagination.pageSize).then((response) => {
        this.data = response.data.data.list
        this.pagination = response.data.data.pagination
      })
    },

    // 弹出新建对话框
    handleOpenDialog() {
      console.log("1")
    },

    // 添加新教室
    handleCreate() {
      createClassroomBuildings().then((response) => {
        this.list = response.data.data.list
        this.pagination = response.data.data.pagination
      })
    },
    formatDate: function (row) {
      return moment(row.time).format('YYYY-MM-DD HH:mm:ss')
    }

  }
}
</script>

<style scoped>

</style>